import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'
import { StarService } from './star.service'
import { CreateStarDto } from './dto/create-star.dto'
import { AuthJWT } from 'src/decorator/auth.decorator'
import { GetUserInfo } from 'src/decorator/getUserInfo.decotator'
import { User } from '@prisma/client'

@Controller('star')
export class StarController {
   constructor(private readonly starService: StarService) {}

   @AuthJWT()
   @Post()
   create(@Body() createStarDto: CreateStarDto, @GetUserInfo() user: User) {
      return this.starService.create(createStarDto, user.id)
   }

   @AuthJWT()
   @Get('/findOne/:articleId')
   findOne(@Param('articleId') articleId: string, @GetUserInfo() user: User) {
      return this.starService.findOne(+articleId, +user.id)
   }

   @AuthJWT()
   @Delete(':id')
   remove(@Param('id') id: string) {
      return this.starService.remove(+id)
   }

   @AuthJWT()
   @Get()
   findAll(@GetUserInfo() user: User) {
      return this.starService.getStarList(+user.id)
   }
}
